package cn.edu.zzuli.nothinglink.controller;

import cn.edu.zzuli.nothinglink.entity.R;
import cn.edu.zzuli.nothinglink.service.NoticeService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/notice")
public class NoticeController {

    @Autowired
    NoticeService noticeService;

    @PostMapping("/put")
    public R put(@RequestBody JSONObject json) {
        if (json.get("courseId") == null
                || json.get("endTime") == null
                || json.get("msg") == null)
            return R.error().add("error", "请检查参数");
        return noticeService.putNotice(json);
    }

    @GetMapping("/get/{courseId}")
    public R get(@PathVariable Integer courseId) {
        return noticeService.getNotice(courseId);
    }

}
